package com.codexsoft.test;

import com.codexsoft.test.entities.User;
import org.apache.wicket.extensions.wizard.WizardStep;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.PropertyModel;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 24.08.11
 * Time: 17:04
 * To change this template use File | Settings | File Templates.
 */
public class RegPanel1 extends WizardStep {
    User user;

    public RegPanel1() {
        super("Register new user: 1-st step", "Please, go through 3 steeps of registration");
        Form form = new Form("regform");
        user = new User();
        TextField name = new TextField("name", new PropertyModel(user, "name"));
        TextField surname = new TextField("surname", new PropertyModel(user, "surname"));
        TextField nickname = new TextField("nickname", new PropertyModel(user, "nickname"));
        TextField password = new TextField("password", new PropertyModel(user, "password"));
        form.add(name);
        form.add(surname);
        form.add(nickname.setRequired(true));
        form.add(password.setRequired(true));
        add(form);
    }

    @Override
    public void applyState() {
        RegistrationWizard.getUser().setName(user.getName());
        RegistrationWizard.getUser().setSurname(user.getSurname());
        RegistrationWizard.getUser().setNickname(user.getNickname());
        RegistrationWizard.getUser().setPassword(user.getPassword());
    }
}
